package com.javaIO.demo1;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class Test {

    public static void main(String[] args) {
        /**
         *  FileOutputStream
         *  new FileOutputStream("demo1.txt""); ====底层创建file
         *  使用输出流写入磁盘的三种方式
         */
        try {
            //指定写入路径
            FileOutputStream fileOutputStream = new FileOutputStream(new File("demo1.txt"));

            //写入内容
//            fileOutputStream.write(97);
//            fileOutputStream.write(98);
//            fileOutputStream.write(99);
//            fileOutputStream.write(100);
            //直接写入字节数组
            byte[] bytes = {97, 98, 99, 100};
//            fileOutputStream.write(bytes);
            //写入 98 99 100
            fileOutputStream.write(bytes, 1, bytes.length - 1);

            //关闭字节输出流
            fileOutputStream.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
